#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for(int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<int> invy(n);
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        p--;
        invy[p] = i;
    }
    vector<int> ans(m);
    vector<set<int>> se(n);
    vector<vector<array<int, 3>>> quer(n);
    for(int i = 0; i < m; i++) {
        int l, r, x;
        cin >> l >> r >> x;
        l--, x--;
        quer[x].push_back({l, r, i});
    }
    auto dfs = [&](auto&& dfs, int u, int fa)->void {
        se[u].insert(invy[u]);
        for(auto x : g[u]) {
            if(x == fa) continue;
            dfs(dfs, x, u);
            if(se[x].size() > se[u].size()) {
                swap(se[x], se[u]);
            }
            se[u].merge(se[x]);
        }
        for(auto [l, r, i] : quer[u]) {
            auto it = se[u].lower_bound(l);
            if(it != se[u].end() && *it < r) {
                ans[i] = 1;
            }
        }
    };
    dfs(dfs, 0, -1);
    for(int i = 0; i < m; i++) {
        if(ans[i]) cout << "YES\n";
        else cout << "NO\n";
    }
    cout << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t; cin >> t;
    while(t--) solve();
    return 0;
}